<%@ page language="java"  import="cn.ac.iscas.bean.softwareCopyright.SoftwareCopyright,cn.ac.iscas.bean.softwareCopyright.SoftwarePicture" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%SoftwareCopyright softwareCopyright = (SoftwareCopyright)request.getAttribute("softwareCopyright"); %>
<html>
  <head>  
    <title>修改项目</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<link rel="stylesheet" href="../../css/vip.css" type="text/css">
	<SCRIPT language=JavaScript src="../../js/jquery.js"></SCRIPT>
    <script language=JavaScript src="../../js/FoshanRen.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js">
    <script type="text/javascript" src="../../js/showNewDiv.js"></script>
    <link rel="stylesheet" type="text/css" href="../../js/extjs/resources/css/ext-all.css"/>
   <script type="text/javascript" charset="utf-8" src="../../js/extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/extjs/ext-all.js"></script>
     <script type="text/javascript"charset="utf-8">
     Ext.onReady(function(){
     var proxy = new Ext.data.HttpProxy({url: "/otcrms/admin/paper/projectBindAction_showProjct.action"});
     var City = Ext.data.Record.create([
     {name: "projectId", type: "int", mapping: "projectId"},
     {name: "name", type: "string", mapping: "name"}
      ]);
     var reader = new Ext.data.JsonReader({
     totalProperty: "totalProperty", //总记录数
      root: "root" //所有的数据（json对象数组）
     }, City);
     var store = new Ext.data.Store({
     proxy: proxy,  
     reader: reader
     });
     var combo = new Ext.form.ComboBox({
     id: "combobox_Id",
     store: store,
     emptyText: "<%if(softwareCopyright.getProject() != null){%>项目编号：<%=softwareCopyright.getProject().getProjectNo()%> 项目名称:<%=softwareCopyright.getProject().getProjectName()%><%}%>",
     mode: "remote",
     pageSize: 7,
     triggerAction: "all",
     displayField: "name",
     valueField: "projectId",
     hiddenName: "project.id",
     renderTo: "project",
     readOnly: true,
     listWidth: 700
     });
      })
    </script>
    <script language="javascript">
    function deleteItem(id){
	 if(confirm("你确定要删除")){
	    $.get("softwareCopyrightManage_deleteDocument.action?softwarePicture.id="+id,
	    function(data){
	    $("#"+id).remove();
	    alert(data);
	    });
      }
    }
   function addApplyingComponent()
   {   
        var tr = document.createElement('tr');
        tr.setAttribute("bgcolor", "f5f5f5");
        var td1 = document.createElement('td');
        td1.setAttribute("width", "25%");
        var td2 = document.createElement('td');
        td2.setAttribute("width", "75%");
       
        var uploadHTML = document.createElement('input');
        uploadHTML.setAttribute("type","file");
        uploadHTML.setAttribute("name","applyingDocument");
        var last = document.getElementById("last");
        var tables = last.parentNode;
       
        tr.appendChild(td1);
        td2.appendChild(uploadHTML);
        tr.appendChild(td2);
        tables.insertBefore(tr,last);
        var button = document.createElement("input");
        button.type = "button";
	    button.value = "删 除"
	    td2.appendChild(button);
        button.onclick = function()
	    {
		tables.removeChild(tr);
	   }
    }
    function len(s){//获取字符串的字节长度
  return s.length+(s.match(/[^\x00-\xff]/g) ||"").length;//加上匹配到的全角字符长度
}
String.prototype.trim=function(){
return this.replace(/(^\s*)|(\s*$)/g,"");
}
function check(){
var reg=/^\d+$/;//判断是非负整数的正则表达式
var LEN400=400,LEN40=40,LEN20=20,LEN200=200;
var f,softwareName,acceptNo,registerNo,copyrightOwner,registerDate,note;
softwareName=document.getElementById("softwareName").value;
if(softwareName.trim()==""){
  alert("著作权名称不可为空！");
  return false;
}
note=document.getElementById("note").value;
if(note!=""){
  if(len(note)>LEN200){
  alert("备注长度超过"+LEN200+"字节！");
  return false;
}
}

f=document.getElementById("myform");
f.submit();
}  
</script> 
   <s:head theme="xhtml"/>
   <sx:head parseContent="true"/>
</head> 
  <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  <s:form id="myform" action="softwareCopyrightManage_update" namespace="/admin/SoftwareCopyrightAction" enctype="multipart/form-data"  method="post">
  <s:hidden name="softwareCopyright.id" value="%{softwareCopyright.id}"/>
  <table id="tables" width="98%" border="0" cellspacing="1" cellpadding="3" align="center">
   
   
 <tr bgcolor="6f8ac4"> 
      <td colspan="2" ><font color="#FFFFFF">软件著作权信息修改：</font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">著作权名称：</div></td>
      <td width="75%"><s:textfield name="softwareCopyright.softwareName" id="softwareName" value="%{softwareCopyright.softwareName}" size="60" maxlength="400"/><font color="#FF0000">*</font></td>
    </tr>
     <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">受理号：</div></td>
      <td width="75%"><s:textfield name="softwareCopyright.acceptNo" value="%{softwareCopyright.acceptNo}" maxlength="40"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">登记号：</div></td>
      <td width="75%"><s:textfield name="softwareCopyright.registerNo" value="%{softwareCopyright.registerNo}" maxlength="40"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">著作权所有人 ：</div></td>
      <td width="75%"><s:textfield name="softwareCopyright.copyrightOwner" value="%{softwareCopyright.copyrightOwner}" maxlength="20"/></td>
    </tr>
     <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">受理日期：</div></td>
       <td width="75%"><input type="text" name="softwareCopyright.acceptDate" class="Wdate" onfocus="WdatePicker()" value="<s:date name="softwareCopyright.acceptDate" nice="false" format="yyyy-MM-dd"/>"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">登记日期：</div></td>
       <td width="75%"><input type="text" name="softwareCopyright.registerDate" class="Wdate" onfocus="WdatePicker()" value="<s:date name="softwareCopyright.registerDate" nice="false" format="yyyy-MM-dd"/>"/></td>
    </tr>
    
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">软著状态：</div></td>
      <td width="75%"><s:radio name="softwareCopyright.state" list="#{'已受理':'已受理','已授权':'已授权 '}" value="%{softwareCopyright.state}"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">选择关联的项目：</div></td>
      <td width="75%"><div id="project"></div></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"> <div align="right">备注 ：</div></td>
      <td width="75%"><s:textarea name="softwareCopyright.note" id="note" cols="60" rows="3" value="%{softwareCopyright.note}"></s:textarea></td>
	</tr>
	 <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">软著相关图片：</div></td>
      <td width="75%"></td>
      </tr>
      <% 
       for(SoftwarePicture pic:softwareCopyright.getPicturePaths())//struts2 我实在不知道在这怎么用
        {%>
       <tr bgcolor="f5f5f5" id="<%=pic.getId()%>"> 
      <td width="25%"> <div align="right"></div></td>
       <td width="75%">
       <font color="#0066FF"><%=pic.getPictureName()%></font>
       <input type="button" value="删除" onClick="deleteItem(<%=pic.getId()%>)"/></td>
       </tr>
      <%}%>
     <tr bgcolor="f5f5f5"> 
     <td width="25%"> <div align="right"></div></td>
      <td width="75%"><input type="button" class="frm_btn" onclick="addApplyingComponent();" value="添加图片" /></td> 
     </tr>
     <tr bgcolor="f5f5f5" id="last" > 
      <td width="25%"> </td>
      <td width="75%"><font color="#0099FF">-------------------------------------------------------------------</font></td>
      </tr>  
    <tr bgcolor="f5f5f5"> 
      <td colspan="2"> <div align="center"> 
          <input type="submit" class="frm_btn" value=" 提 交 " onclick="return check();">
          &nbsp;&nbsp;<input type="button" name="Button" value=" 返 回 " class="frm_btn" onclick="javascript:history.back()">
        </div></td>
    </tr>
  </table>
</s:form>
  </body>
</html>
